-- @owner: wan005
-- @date: 2024-08-12
-- @testpoint: quote()函数作为对象名的测试

--prestep1:切换B库;expect:执行成功
@conn PrimaryDbBmode;
show sql_compatibility;

--step1:作为列名;expect:成功
drop table if exists quote_test cascade;
create table quote_test(quote text);
insert into quote_test values('0');

--step2:作为索引名;expect:成功
create index quote on quote_test(quote);
drop index quote;

--step3:作为表名;expect:成功
drop table if exists quote cascade;
create table quote(quote text);
drop table quote cascade;

--step4:作为数据库名;expect:成功
drop database if exists quote;
create database quote;
drop database quote;

--step5:作为外部数据源名;expect:成功
drop data source if exists quote;
create data source quote;
drop data source quote;

--step6:作为自定义函数名;expect:成功
create or replace function quote(c1 int)
returns int
as  $$
begin
    return c1;
end;
$$language plpgsql;
/
drop function if exists quote(int);

--step7:作为存储过程名;expect:成功
drop table if exists t_quote_0019;
create table t_quote_0019(c1 int);
CREATE OR REPLACE PROCEDURE quote(P1 IN int) AS
BEGIN
insert into t_quote_0019 values ('00001');
raise info '测试quote作为存储过程名';
END;
/
drop procedure if exists quote(int);

--step8:作为角色名;expect:成功
drop role if exists quote;
create role quote with password 'gauss@123' valid until '2001-12-12';
drop role quote;

--step9:作为用户组名;expect:成功
drop group if exists quote;
create group quote with password 'gauss@123';
drop group quote;

--step10:作为模式名;expect:成功
drop schema if exists quote;
create schema quote;
drop schema quote;

--step11:作为序列名;expect:成功
create sequence public.quote start 100 cache 50;
drop sequence public.quote;

--step12:作为用户名;expect:成功
drop user if exists quote;
CREATE USER quote PASSWORD 'Bigdata@123';
drop user quote;

--step13:作为游标名;expect:成功
drop table if exists quote_test cascade;
create table quote_test(cid int,fid int);
start transaction;
cursor quote for select * from quote_test order by 1;
close quote;
end;

--step14:清理环境;expect:成功
drop table if exists quote_test cascade;
drop table if exists quote cascade;
drop table if exists t_quote_0019;